
/***
 * 统计代码统一 by peilan
 * 在webpack配置文件中先引入，例如开发版
 * new HtmlWebpackPlugin({
        template: path.resolve( __dirname, 'template/index.ejs' ),
        filename: 'index.html',
        chunks: ['index','vendor','manifest'],
        title: '恋爱对象心理测试',
        cdn: '../forecastassetbundle/js/bj-report-tryjs.min.js',
        statistics: '../forecastassetbundle/js/statistics.js'
    }),
    生产版：
    statistics: JSON.stringify(sdk.formatCdnPath({ projectName: 'forecastassetbundle', afterPath: '/js/statistics.js'}))
 * 
 * 在ejs中引入<script src=<%= htmlWebpackPlugin.options.statistics %>></script> 这样就OK了，是不是简单了很多
 * 就算以后修改统计代码，也不用去编译每个测算了
 */

 //百度统计
;(function() {
    var types = {
        zxcsLinghit:function() {
            window._hmt = window._hmt || [];
            (function() {
                var hm = document.createElement("script");
                hm.src = "//hm.baidu.com/hm.js?da9f609f31e08775a3c08224838230b5";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();
        },
        Tencent: function(){
            var _mtac = {"performanceMonitor":1,"senseQuery":1};
            (function() {
                var mta = document.createElement("script");
                mta.src = "//pingjs.qq.com/h5/stats.js?v2.0.4";
                mta.setAttribute("name", "MTAH5");
                mta.setAttribute("sid", "500623120");
                mta.setAttribute("cid", "500623313");
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(mta, s);
            })();  
        }
    }

    var statisticsCodes = [ 'zxcsLinghit', 'Tencent'];

    statisticsCodes.forEach( function(v) {
        types[v].apply(this);
    });

})()

//新大数据埋点sdk引入
;(function() {
    var mta = document.createElement("script");
    mta.src = "//aicdn.linghit.com/sense-sdk/latest/sense.sdk.min.js";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(mta, s);
})()


// growingIO统计
/**
 * 使用方法
 * 在需要加入改统计的页面中加入
 * 
   <script type='text/javascript'>
        gio('init', 'yishengcaiyun', {});
        gio('send');
    </script>

    需要修改：yishengcaiyun，表示项目id（具体到每个测算就用每个测算项目名就行）

    // 线上sdk地址：assets.growingio.com/2.1/gio.js
        换成了本地：../forecastassetbundle/js/growingio.js
 * 
 */
// !(function (e, t, n, g, i) {
//     e[i] = e[i] || function () { (e[i].q = e[i].q || []).push(arguments) },
//         n = t.createElement("script"),
//         tag = t.getElementsByTagName("script")[0],
//         n.async = 1,
//         // n.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + g,
//         n.src = g,
//         tag.parentNode.insertBefore(n, tag)
// })(window, document, "script", "../forecastassetbundle/js/growingio.js", "gio");

